package com.fub.guidance;

import java.util.List;

public class Building {
	private List<Wall> walls;
	private static Building instance;

	/**
	 * Returns an instance of this class (singleton pattern).
	 * 
	 * @return an instance of this class
	 */
	public static Building getInstance() {
		if (instance == null) {
			instance = new Building();
		}
		return instance;
	}

	private Building() {
	}

	/**
	 * Sets the walls of this building.
	 * 
	 * @param the
	 *            walls of this building
	 */
	public void setWalls(List<Wall> walls) {
		this.walls = walls;
	}

	/**
	 * Returns the walls of this building.
	 * 
	 * @return the walls of this building
	 */
	public List<Wall> getWalls() {
		return this.walls;
	}

	/**
	 * Returns the maximum x coordinate of all walls.
	 * 
	 * @return the maximum x coordinate of all walls
	 */
	public float getMaxX() {
		int max = 0;
		for (Wall wall : this.walls) {
			if (wall.getX1() > max) {
				max = wall.getX1();
			}
			if (wall.getX2() > max) {
				max = wall.getX2();
			}
		}
		return max;
	}

	/**
	 * Returns the maximum y coordinate of all walls.
	 * 
	 * @return the maximum y coordinate of all walls
	 */

	public float getMaxY() {
		int max = 0;
		for (Wall wall : this.walls) {
			if (wall.getY1() > max) {
				max = wall.getY1();
			}
			if (wall.getY2() > max) {
				max = wall.getY2();
			}
		}
		return max;
	}
}
